package com.wwp.tbshop.presenter;

import com.wwp.tbshop.model.bean.AddressList;
import com.wwp.tbshop.model.bean.BaseBean;
import com.wwp.tbshop.model.bean.BrandRecommendBean;
import com.wwp.tbshop.model.bean.CartAddBean;
import com.wwp.tbshop.model.bean.CartQueryBean;
import com.wwp.tbshop.model.bean.CategoryVo;
import com.wwp.tbshop.model.bean.CollectListBean;
import com.wwp.tbshop.model.bean.CollectionBean;
import com.wwp.tbshop.model.bean.ConfirmBean;
import com.wwp.tbshop.model.bean.DeleteBean;
import com.wwp.tbshop.model.bean.ExitBean;
import com.wwp.tbshop.model.bean.GoodsListBean;
import com.wwp.tbshop.model.bean.HomeBean;
import com.wwp.tbshop.model.bean.HotProductBean;
import com.wwp.tbshop.model.bean.InvoiceInfoBean;
import com.wwp.tbshop.model.bean.KeywordBean;
import com.wwp.tbshop.model.bean.LimitBuyBean;
import com.wwp.tbshop.model.bean.LoginBean;
import com.wwp.tbshop.model.bean.NewGoodsBean;
import com.wwp.tbshop.model.bean.OrderSubmitResponseBean;
import com.wwp.tbshop.model.bean.ProductDetailBean;
import com.wwp.tbshop.model.bean.RegisterBean;
import com.wwp.tbshop.model.bean.SaleNewsBean;
import com.wwp.tbshop.model.bean.SearchBean;
import com.wwp.tbshop.model.bean.SearchListBean;
import com.wwp.tbshop.model.bean.UpdateBean;
import com.wwp.tbshop.model.bean.UserInfoBean;

import java.util.Map;

import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;

/**
 * Created by dada on 2017/6/14.
 */


public interface ApiService {


    //1,主页轮播图；
    @GET("home")
    Call<HomeBean> getHomePic();

    //2,促销快报http://localhost:8080/market/topic?page=2&pageNum=10

    @GET("topic")
    Call<SaleNewsBean> getSaleNews(
            @Query("page") String page,
            @Query("pageNum") String pageNum
    );

    @GET("limitbuy")
    Call<LimitBuyBean>getLimtBuyGoods(
            @Query("page") String page,
            @Query("pageNum") String pageNum
    );

    @GET("newproduct")
    Call<NewGoodsBean>getNewGoods(
            @Query("page") String page,
            @Query("pageNum") String pageNum,
            @Query("orderby") String orderby
    );

    @GET("hotproduct")
    Call<HotProductBean>getHotProducts(
            @Query("page") String page,
            @Query("pageNum") String pageNum,
            @Query("orderby") String orderby
    );


//http://localhost:8080/market/brand/plist?page=1&pageNum=10&id=1213&orderby=saleDown

    //品牌
    @GET("brand")
    Call<BrandRecommendBean>getRecommendBrand();

    /**结算中心信息*/
    @FormUrlEncoded
    @POST("checkout")
    Call<ConfirmBean> getConfirmInfo(@Header("userid") String userId, @Field("sku") String sku);


    /*===============  ===============*/

    /**
     * 查询商品
     */
    @GET("search")
    Call<SearchBean> searchProduct(
            @Query("page") String page,
            @Query("pageNum") String pageNum,
            @Query("orderby") String orderby,
            @Query("keyword") String keyword
    );

    @GET("search")
    Call<SearchBean> searchProduct2(@QueryMap Map<String, String> params);

    /**
     * 登录操作
     */
    @FormUrlEncoded //POST请求中
    @POST("login")
//定义
    Call<LoginBean> login(@Field("username") String username,
                          @Field("password") String password);

    @FormUrlEncoded
    @POST("login")
    Call<LoginBean> login2(@FieldMap Map<String, String> params);

    /**
     * 获取用户信息;
     */
    @GET("userinfo")
    Call<SearchBean> getUserInfo(@Header("userid") String userid);

    /**商品详情轮播图**/
    @GET("product")
    Call<ProductDetailBean> getProductPic(@Query("pId") int pId);

    /**分类页面请求*/
    @GET("category")
    Call<CategoryVo> getCategoryInfo();

    //账号信息
    //POST请求中
    @GET("userinfo")
    Call<UserInfoBean> login_userinfo(@Header("userid") String userId);

    /*
    * 购物车
    */
    @GET("addCart")
    Call<CartAddBean> AddCartInfo(@Query("userId") String userId, @Query("productId") String productId, @Query("productCount") String productCount, @Query("propertyId") String propertyId);

    @GET("selectCart")
    Call<CartQueryBean> getCartInfo(@Query("userId") String userId);

    @GET("updateCart")
    Call<UpdateBean> updateCartInfo(@Query("userId") String userId, @Query("productId") String productId, @Query("productCount") String productCount, @Query("propertyId") String propertyId);

    @GET("deleteCart")
    Call<DeleteBean> deleteCartInfo(@Query("userId") String userId, @Query("productId") String productId);

    // 注册
    @GET("register")
    Call<RegisterBean> registerUser(@Query("username") String username, @Query("password") String password);

    // 注销用户
    @GET("logout")
    Call<ExitBean> exitUser(@Header("userId") String userid);
    /**获取地址信息;*/
    @GET("addresslist")
    Call<AddressList> getAddressList(@Header("userid") int userid);

    /**默认地址;*/
    @FormUrlEncoded
    @POST("addressdefault")
    Call<BaseBean> setAddressDefault(@Field("id") int id,@Header("userid") int userid );

    /**删除地址;*/
    @FormUrlEncoded
    @POST("addressdelete")
    Call<BaseBean> deleteAddress(@Field("id") int id,@Header("userid") int userid);

    ///addresssave
    /**修改地址;*/
    @FormUrlEncoded
    @POST("addresssave")//
    Call<BaseBean> saveAddress(
            @Field("id") String id,
            @Field("name") String name,
            @Field("phoneNumber") String phoneNumber,
            @Field("province") String province,
            @Field("city") String city,
            @Field("addressArea") String addressArea,
            @Field("addressDetail") String addressDetail,
            @Field("zipCode") String zipCode,
            @Field("isDefault") int isDefault,
            @Header("userid") int userid
    );

    /**商品收藏**/
    @GET("product/favorites")
    Call<CollectionBean> addCollection(@Header("userId") String userId, @Query("pId") int pId);

    /**收藏夹;*/
    @GET("favorites")
    Call<CollectListBean> getCollectList(
            @Query("page") int page,
            @Query("pageNum") String pageNum,
            @Header("userid") String userid
    );

    /**商品列表*/
    @GET("productlist")
    Call<GoodsListBean> getGoodsList(
            @Query("page") int page,
            @Query("pageNum") int pageNum,
            @Query("cId") int cId,
            @Query("orderby") String orderby,
            @Query("filter") String filter);

    /**推荐搜索词;*/
    @GET("search/recommend")
    Call<KeywordBean> getKeyword();

    /**搜索;*/
    @GET("search")
    Call<SearchListBean> searchGoodsList(
            @Query("keyword") String keyword,
            @Query("page") int page,
            @Query("pageNum") int pageNum,
            @Query("orderby") String orderby
    );

    @GET("invoice")
    Call<InvoiceInfoBean> getInvoice();


    @FormUrlEncoded
    @POST("ordersumbit")
    Call<OrderSubmitResponseBean> submitOrder(@Header("userId") String id,
                                              @Field("sku") String sku,
                                              @Field("addressId") String addressId,
                                              @Field("paymentType") String paymentType,
                                              @Field("deliveryType") String deliveryType,
                                              @Field("invoiceType") String invoiceType,
                                              @Field("invoiceTitle") String invoiceTitle,
                                              @Field("invoiceContent") String invoiceContent
    );

}
